﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

/// <summary>
/// Summary description for ucGroupProductViewer
/// </summary>
public class ucGroupProductViewer
{
    public static string View()
    {
        StringBuilder str = new StringBuilder();
        CGroupProductLevelParentFacade facade = new CGroupProductLevelParentFacade();
        CGroupProductFacade facadeGroup = new CGroupProductFacade();
        IList<GroupProductLevelParent> list = facade.List(0);
        foreach (GroupProductLevelParent item in list)
        {
            str.Append("<div class='group product'>");
            str.AppendFormat(_formatGroup, item.Name);
            IList<GroupProduct> listGroup = facadeGroup.List(1, 100, 0, item.Id, 1);
            foreach (GroupProduct itemGroup in listGroup)
            {
                str.AppendFormat(_formatGroupItem, itemGroup.GroupProductName, itemGroup.GroupProductId);
            }
            str.Append("</div>");
        }
        return str.ToString();
    }

    static string _formatGroup = @"<div class='item title'><label>{0}</label></div>";
    static string _formatGroupItem = @"<div class='item'><label><a href='../Pages/NewProducts.aspx?gpi={1}'>> {0}</a></label></div>";
}